/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.gwt.apps.client;

import net.bioteam.appweb.gwt.apps.client.program.ProgramFormHolder;
import net.bioteam.appweb.gwt.apps.client.user.JobPanel;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.VStack;

public class ContentPanel extends VStack
{

	
	Canvas visibleItem;
	public ContentPanel()
	{
		setWidth100();
		setHeight100();
		
		setStyleName("mycontent");
		
		
		//ProgramForm form=new ProgramForm();
		//StaticHolder.programForm=form;
		ProgramFormHolder formHolder=new ProgramFormHolder();
		formHolder.setVisible(false);
		StaticHolder.programFormHodler=formHolder;
		addMember(formHolder);
		
		//initialize this so this component is always available.
		JobPanel jPanel=new JobPanel();
		StaticHolder.jobPanel=jPanel;
		jPanel.setVisible(false);
		addMember(jPanel);
		
	}
	
	public void switchPanel(Canvas target)
	{
		if(visibleItem!=null)
			visibleItem.hide();
		target.show();
		
		String previousID=null;
		if (visibleItem!=null)
			previousID=visibleItem.getID();
		if (previousID==null)
			previousID="";
		String targetID=target.getID();
		if (targetID==null)
			targetID="";
		if (targetID.equals("_jobPanel") && !previousID.equals("_jobPanel"))
		{
			StaticHolder.appTreeGrid.resizeBy(-150, 0);	
		} else if (!targetID.equals("_jobPanel") && previousID.equals("_jobPanel"))
		{
			StaticHolder.appTreeGrid.resizeBy(150, 0);	
		}
		visibleItem=target;	
	}
}
